/**
 * 
 */
package com.gmail.blackdog1987.carcare.web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gmail.blackdog1987.carcare.service.OrderService;
import com.gmail.blackdog1987.carcare.util.ErrorCode;
import com.gmail.blackdog1987.carcare.web.dto.JsonResult;

/**
 * 
 * @author 董国超
 *
 */
@Controller
public class OrderController extends BaseController {
	@Autowired
	private OrderService orderService;
	
	@ResponseBody
	@RequestMapping(value="orderdrivecompany", method=RequestMethod.POST)
	public JsonResult orderdrivecompany(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderDriveCompany(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="ordercarrent", method=RequestMethod.POST)
	public JsonResult ordercarrent(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderCarRent(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="ordercarsale", method=RequestMethod.POST)
	public JsonResult ordercarsale(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderCarSale(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="orderclean", method=RequestMethod.POST)
	public JsonResult orderclean(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderClean(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="ordermaintain", method=RequestMethod.POST)
	public JsonResult ordermaintain(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderMaintain(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="orderroadhelp", method=RequestMethod.POST)
	public JsonResult orderroadhelp(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderRoadHelp(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="orderrulescheck", method=RequestMethod.POST)
	public JsonResult orderrulescheck(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderRulesCheck(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="ordercarfix", method=RequestMethod.POST)
	public JsonResult ordercarfix(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderCarFix(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="ordercarchange", method=RequestMethod.POST)
	public JsonResult ordercarchange(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderCarChange(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
	
	@ResponseBody
	@RequestMapping(value="orderdriveschool", method=RequestMethod.POST)
	public JsonResult orderdriveschool(@RequestParam Map<String, String> filter, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = orderService.saveOrderDriveSchool(filter);
		if(!ErrorCode.NO.equals(result.get("code").toString())){
			return new JsonResult(Boolean.FALSE, result.get("code").toString(), result.get("msg")==null?"":result.get("msg").toString(), null);
		}
		return new JsonResult(Boolean.TRUE, result.get("result"));
	}
}
